package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.entity.Orders;
import com.sky.vo.OrderVO;
import com.sky.vo.OrdersDetailVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    void insert(Orders order);

    Orders getOrder(@Param("orderId")Long orderId, @Param("userId") Long userId);
    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    Orders getByNumber(@Param("outTradeNo") String outTradeNo);

    Page<OrdersDetailVO> getOrders(Orders orders);



    Page<OrderVO> getOrdersTimeRange(@Param("orders") Orders orders,@Param("beginTime") LocalDateTime beginTime,@Param("endTime") LocalDateTime endTime);

    Integer getOrderStatusCount(@Param("status") Integer status);

    List<Orders> getByStatusAndOrderTimeLT(@Param("status") Integer status,@Param("orderTime") LocalDateTime orderTime);

    /**
     * 每天凌晨一点将状态为派送中的订单设置为已完成
     * @param status
     * @return
     */
    List<Orders> getOrdersDelivery(@Param("status") Integer status);

    Integer countByMap(@Param("map") Map map);

    Double sumByMap(@Param("map") Map map);
}
